<template>
  <div class="component-root-container">
    <el-header>
      <el-form ref="projectRule" :rules="projectRule" :model="project" label-width="120px" label-position="right">
        <el-row>
          <el-col :span="8">
            <el-form-item label="合同编码:" prop="contractNo">
              <el-input v-model="project['contractNo']" placeholder="请输入" @input="change($event)" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业主编号:" prop="otherbodycode">
                <el-input v-model="project['otherbodycode']" placeholder="请输入" @input="change($event)" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业主名称:" prop="otherbodyname">
              <el-input v-model="project['otherbodyname']" placeholder="请输入" @input="change($event)" clearable />
            </el-form-item>
          </el-col>
          </el-row>
          <el-row>
          <el-col :span="8">
            <el-form-item label="银行账号:" prop="account">
                <el-input v-model="project['account']" placeholder="请输入" @input="change($event)" clearable />
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="账户名:" prop="accountName">
              <el-input v-model="project['accountName']" placeholder="请输入" @input="change($event)" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="开户联号:" prop="bankChain">
                <el-input v-model="project['bankChain']" placeholder="请输入" @input="change($event)" clearable />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
            <el-col :span="8">
            <el-form-item label="地市编码:" prop="ownerCityCode">
                <el-input v-model="project['ownerCityCode']" placeholder="请输入" @input="change($event)" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8" :offset="8" class="col_button">
            <div class="button">
              <el-button class="query" @click="buttonClick">
                查询
              </el-button>
              <el-button class="query" @click="reset">
                重置
              </el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-header>

    <el-main>
      <div class="contentInfo" style="margin-bottom:20px;">
        <el-row>
          <el-col class="header-title">
            <span class="header-vertical" />
            场景使用情况
          </el-col>
        </el-row>
        <el-row>
          <div class="inline">
            <div><span>调用次数/日：</span><span>{{ queryCount }}</span></div>
            <div><a class="link" href="javascript:;" @click="$router.push({name:'biz-ml'})">详情</a></div>
          </div>
        </el-row>
      </div>
      <div class="contentInfo">
        <el-row>
          <el-col class="header-title">
            <span class="header-vertical" />
            场景说明
          </el-col>
        </el-row>
        <el-row>
          <div class="page-tip">
            <div class="description">实现在物业系统发起场租电费支付时，支付单中的选定的收款账户信息都应在合同系统已与合同进行绑定付款账户，保障场租电费的支付账户从源头管理，以及收款账户信息从合同系统至物业系统的刚性同步，确保场租电费支付的付款账户与合同绑定的账户信息刚性一致。</div>
          </div>
          <div class="page-tip" @click.ctrl.alt="clickExample">
            <div class="params-tip"><span>示例参数</span>：合同编码: CTC-JXNC-2021-000133, 业主编号: 020401003052, 业主名称: 熊黄亮, 银行账号: 6217906500002962635, 账户名: 熊黄亮, 开户联号: 104421010194, 地市编码: 360100</div>
          </div>
        </el-row>
      </div>
    </el-main>
    <el-main>
      <div class="contentInfo">
        <el-row>
          <el-col class="header-title">
            <span class="header-vertical" />
            校验结果
          </el-col>
        </el-row>
        <el-row>
          <div class="page-tip">
            <div class="description">
              <!-- <div> {{ dialog.title }} </div> -->
              <el-row v-for="(item,index) in dialog.content" :key="index" class="dialog-row">
                <el-col>
                  {{ item.returnMsg }}
                </el-col>
              </el-row>
            </div>
          </div>
        </el-row>
      </div>
    </el-main>

  </div>


</template>

<script>
  import mixin from './mixins'
  export default {
    mixins: [mixin],
    data() {
      return {
        dialogVisible: false,
        queryCount:0,
        project: {
            contractNo: '',
            otherbodycode: '',
            otherbodyname: '', 
            account: '',
            accountName: '', 
            bankChain: '', 
            seriesNo: '1',
            ownerCityCode: ''
        },
        dialog: {
          title: '',
          content: []
        },
        options: [{
            value: 'tssai',
            key: '1'
          }
        ],
        projectRule: {
          contractNo: [{
            required: true,
            message: '请输入合同编码',
            trigger: 'blur'
          }],
          otherbodycode: [{
            required: true,
            message: '请输入业主编号',
            trigger: 'blur'
          }],
          otherbodyname: [{
            required: true,
            message: '请输入业主名称',
            trigger: 'blur'
          }],
          account: [{
            required: true,
            message: '请输入银行账号',
            trigger: 'blur'
          }],
          accountName: [{
            required: true,
            message: '请输入账户名',
            trigger: 'blur'
          }],
          bankChain: [{
            required: true,
            message: '请输入开户联号',
            trigger: 'blur'
          }],
          ownerCityCode: [{
            required: true,
            message: '请输入地市编码',
            trigger: 'blur'
          }]
        }
      }
    },
    created() {
      this.queryPageCount('3.3');
    },
    mounted() {},
    computed: {},
    methods: {
      async buttonClick() {
        try {
          this.dialog = {
            title: '',
            content: []
          }

          await this.$refs['projectRule'].validate()
          const data = {
            contractNo: this.project['contractNo'],
              otherbodycode: this.project['otherbodycode'],
              otherbodyname: this.project['otherbodyname'],
              account: this.project['account'],
              accountName: this.project['accountName'],
              bankChain: this.project['bankChain'],
              seriesNo: this.project['seriesNo'],
              ownerCityCode: this.project['ownerCityCode']
          }
          const r = await this.$http({
            url: this.$http.adornBizUrl('/phase/three/supplier/info/verification'),
            method: 'post',
            data: this.$http.adornData('param=' + JSON.stringify(data), false),
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
            }
          })
          console.log(r.data);
          if (r.data.resultStat ==="000") {
            // console.log(r.data.data.retiurnMsg)
            this.dialog.content = r.data.data
            
            // this.dialog.title = r.data.data.retiurnMsg
          }else{
              this.dialog.title = r.data.mess
          }
          this.dialogVisible = true
        } catch (e) {
          console.log(e)
        } finally {
          this.listLoading = false
        }
      },
      getTitle(key) {
        const option = this.options.filter(o => o.key === key)
        let value = null
        if (option[0]) {
          value = option[0].value
        }
        return value
      },
      reset() {
        this.project = {
          prjCode: '',
          operationId: ''
        }

        this.dialog = {
          title: '',
          content: []
        }
        this.$refs['projectRule'].clearValidate();
      },
      change(e) {
        this.$forceUpdate()
      },

      async queryPageCount(scene) {
        try {
          const r = await this.$http({
            url: this.$http.adornBizUrl('/log/queryStatistics'),
            method: 'post',
            data: this.$http.adornData('param=' + JSON.stringify({scene:scene}), false),
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
            }
          })
          if(r.data.data && r.data.data.length >0){
              var result = r.data.data[0];
              this.queryCount=result.cnt||'0';
          }
        } catch (e) {
          console.log(e)
        } finally {
        }
      }
    }
  }
</script>

<style scoped lang="scss">
  @import "../../../assets/scss/formatQueryPage";
  @include formatQueryPage(120px, 60%);
  .el-input {
    width: 60%;
  }

  .el-select {
    width: 60%;
  }

  .query {
    color: rgba(255, 255, 255, 1);
    background: rgba(235, 75, 75, 1);
    border-radius: 6px;
    border-color: rgba(235, 75, 75, 1);
  }
  .custom-button {
    display: flex;
    justify-content: center;
  }

  .dialog-row {
    margin-bottom: 5px;
  }
</style>
